package com.easycms.framework.configs;


import com.easycms.framework.interceptor.EasyInterceptor;

import org.springframework.context.annotation.Configuration;

import org.springframework.util.AntPathMatcher;
import org.springframework.web.servlet.config.annotation.*;
/**
 * @author yushuo
 * @description //TODO
 * @date 10:59 2021/6/3
 * @param
 * @return
**/
@Configuration
public class EasyWebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new EasyInterceptor())
                // 表示拦截的 URL
                .addPathPatterns("/**")
                .excludePathPatterns("/","/login","/ui/**");
                // 表示需要排除的路径 放行的请求;
              //  .excludePathPatterns("/","/login","/ui/**");
               //.excludePathPatterns("/","/login","/ui/**",/fonts/**","/images/**","/js/**");
    }

    /**资源过滤器**/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        //本地文件上传路径
        // registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");

       //swagger配置
        //registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/")
               .addResourceLocations("E:/JavaWork/easycmsboot/src/main/resources/static/**");

          //super.addResourceHandlers(registry);
    }


    /**
    * 访问路径大小写不敏感开启
    * */
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        AntPathMatcher matcher = new AntPathMatcher();
        //配置url访问大小写不敏感
        matcher.setCaseSensitive(false);
        configurer.setPathMatcher(matcher);
    }

}
